select name from master..sysdatabases
WHERE DATABASEPROPERTYEX(name, 'Status') = 'ONLINE'
